package com.ruitu.health_1.mvp.presenter;

import com.ruitu.arad.base.BasePresenter;
import com.ruitu.health_1.mvp.model.AutoLoginModel;
import com.ruitu.health_1.mvp.model.LoginModel;
import com.ruitu.health_1.ui.fragment.MineFragment;
import com.ruitu.router_module.bean.BaseResult2;
import com.ruitu.router_module.bean.user.User;

import io.reactivex.disposables.Disposable;
import io.reactivex.functions.Consumer;
import okhttp3.RequestBody;

public class AutoLoginPresenter {
    public static class AutoLogin extends BasePresenter<MineFragment, AutoLoginModel.AutoLoginM> {
        public Disposable autoLogin(RequestBody body) {
            return m.autoLogin(body).subscribe(new Consumer<BaseResult2<User>>() {
                @Override
                public void accept(BaseResult2<User> userBaseResult2) throws Exception {
                    if (userBaseResult2.isSuccess()) {
                        v.setUserData(userBaseResult2.getData());
                    }
                }
            }, new Consumer<Throwable>() {
                @Override
                public void accept(Throwable throwable) throws Exception {
                    throwable.printStackTrace();
                }
            });
        }
    }

}
